Author

Tony Duan

send email with {blastula}

Code
library(blastula)
library(keyring)

create smtp credentials

gmail

Code
create_smtp_creds_key(
  id = "gmail001_creds",
  provider = "gmail",
  user = "verykoala@gmail.com",
  overwrite = TRUE
  )

outlook

Code
# create_smtp_creds_key(
#   id = "outlook001_creds",
#   provider = "outlook",
#   user = "jcpartner@outlook.com",
#   overwrite = TRUE
#   )

create_smtp_creds_file(file = "ggnot_throwaway_creds",
                       user = "jcpartner@outlook.com",
                       provider = "outlook")
Code
#delete_credential_key("gmail001_creds")
Code
view_credential_keys()

email content

Code
library(blastula)
msg=compose_email(
  body = md(
  "Hi there 👋,
  
  This is an email to let you now thatrunning job **finished**.

  Best,<br>
  Tony"
  )
)

msg

send email

send from gmail

Code
msg %>% 
  smtp_send(
    from = 'verykoala@gmail.com',
    to = "jcflyingco@outlook.com",
    subject = "Testing the email function",
    credentials = creds_key(id = "gmail001_creds")
  )

send from outlook

Code
library(Microsoft365R)
outl <- get_personal_outlook()
Code
# list the most recent emails in your Inbox
#outl$list_emails()
Code
em <- outl$create_email(msg, subject="Hello", to="jcflyingco@outlook.com")
Code
em$send()

send email with quarto content

Code
email_obj=render_email('.quarto_email.Rmd')
Code
email_obj

send from gmail

Code
email_obj%>% 
  smtp_send(
    from = 'verykoala@gmail.com',
    to = "jcflyingco@outlook.com",
    subject = "Testing the email function",
    credentials = creds_key(id = "gmail001_creds")
  )

send from outlook

Code
em <- outl$create_email(email_obj, subject="Hello", to="jcflyingco@outlook.com")
em$send()

Reference:

https://www.youtube.com/watch?v=PihKq1GPlcc

Back to top